package com.eco.fanliapp.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.entity.AppUser;
import com.eco.fanliapp.vo.AppUserFansTeamVo;
import com.eco.fanliapp.vo.ChannelUserAffiliationVo;
import com.eco.fanliapp.vo.WithdrawalInfo;
import com.eco.fanliapp.vo.respone.ResponeOrderResults.OrderDataBean;
import com.github.pagehelper.PageInfo;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * APP用户 服务层
 * 
 * @author xiaoxx
 * @date 2019-04-24
 */
public interface IAppUserService extends IService<AppUser>
{
	/**
     * 查询APP用户信息
     * 
     * @param tableId APP用户ID
     * @return APP用户信息
     */
	AppUser selectAppUserById(Long tableId);
	
	/**
     * 查询APP用户列表
     * 
     * @param appUser APP用户信息
     * @return APP用户集合
     */
	List<AppUser> selectAppUserList(AppUser appUser);
	
	/**
     * 新增APP用户
     * 
     * @param appUser APP用户信息
     * @return 结果
     */
	int insertAppUser(AppUser appUser);
	
	/**
     * 修改APP用户
     * 
     * @param appUser APP用户信息
     * @return 结果
     */
	int updateAppUser(AppUser appUser);
		
	/**
     * 删除APP用户信息
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	int deleteAppUserByIds(String ids);

	AppUser selectAppUserByPhoneNumber(String state);

	/**
	 * 根据微信ID查询用户
	 * @param wechatUnionid
	 * @return
	 */
	AppUser selectAppUserByWechatUnionid(String wechatUnionid);

	ServerResponse<PageInfo> selectAppUserListByUserName(String userName, Integer currentPage, Integer pageSize, Integer companyId);

	/**
	 * 根据上级邀请码查询粉丝
	 * @param superInviteCode
	 * @return
	 */
    List<AppUser> selectFansBySuperInviteCode(String superInviteCode);


	/**
	 * 根据微信ID下载用户
	 * @param wechatUnionid
	 * @return
	 */
	boolean downloadUserInformationByWechatUnionid(String wechatUnionid);

	/**
	 * 根据淘宝Id查询APP用户信息
	 *
	 * @return APP用户信息
	 */
	WithdrawalInfo selectAppUserByTaoBaoUserId(Long userId, Integer currentPage, Integer pageSize);

	/**
	 * 修改用户支付宝
	 * @param userId
	 * @param zname
	 * @param znumber
	 * @return
	 */
	ServerResponse<JSONObject> updateAppUserAlipay(Long userId, String zname, String znumber, String phoneNumber);


	/**
	 * 新增用户支付宝信息
	 * @param userId
	 * @param zname
	 * @param znumber
	 * @return
	 */
	ServerResponse<JSONObject> addAppUserAlipay(Long userId, String zname, String znumber, String phoneNumber);

	/**
	 * 我的收益的3个值
	 * @param userId
	 * @return
	 */
	ServerResponse<JSONObject> findAppUserBybalance(Long userId);

	int updateAppUserbalance(Long userId, BigDecimal money);

	/**
	 * 分页查询用户信息
	 * @param currentPage
	 * @param pageSize
	 * @param userName
     * @return
	 */
	ServerResponse<PageInfo> selectAppUserListByPaging(Integer currentPage, Integer pageSize, Integer companyId, String userName);

	AppUser selectAppUserBybalance(Long userId);

	void downloadUserInformation(HttpServletResponse response, String username);

	/**
	 * 我的团队
	 * @param long1
	 * @return
	 */
	ServerResponse<Map<String, Object>> teamAll(Long long1);


	/**
	 * 我的粉丝--粉丝人数 粉丝贡献
	 * @param long1
	 * @return
	 */
	ServerResponse<Map<String, Object>> teamFans(Long long1);

	/**
	 * 根据userId查询用户详情-从redis或者数据库
	 * @param userId
	 * @param type  0实时从数据库1优先从redis
	 * @return
	 */
	AppUser selectAppUserByUserId(Long userId,int type);
	/**
	 * 根据userId查询用户详情
	 * @param userId
	 * @return
	 */
	AppUser selectAppUserByUserId(long userId);

	/**
	 * 我的团队下面的粉丝贡献
	 * @param appUserId
	 * @param name
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	ServerResponse<List<Map<String, Object>>> teamOrderDetail(Long appUserId, String name, Integer pageNum, Integer pageSize);

	/**
	 * 用上级的邀请吗查询自己的上级
	 * @param superInviteCode
	 * @return
	 */
	AppUser selectSuperUserInfoBySuperInviteCode(String superInviteCode);


	/**
	 * 渠道ID查询
	 * @param relationId
	 * @return
	 */
	AppUser selectUserInfoByRelationId(Long relationId);
	/**
	 * 会员ID查询
	 * @param specialId
	 * @return
	 */
	AppUser selectUserInfoBySpecialId(Long specialId);
	/**
	 * 增加可提现金额
	 * @param userId
	 * @param commission
	 * @return
	 */
	int updateAppUseraddbalance(Long userId, BigDecimal commission);

	/**
	 * 我的团队订单
	 * @param appUserId
	 * @param tkStatus
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	ServerResponse<List<OrderDataBean>> TeamOrder(Long appUserId, Integer tkStatus, Integer pageNum, Integer pageSize);

	/**
	 * 累计收益查询
	 * @param appUserId
	 * @return
	 */
	ServerResponse<Map<String, Object>> findbalanceIncome(Long appUserId);
	/**
	 * 累计补贴-查询 订单补贴 粉丝贡献 订单数量，总收益
	 * @param appUserId
	 * @return
	 */
	ServerResponse<Map<String, Object>> findBalanceIncome(Long appUserId);

	/**
	 * 查询我的补贴
	 * @param appUserId
	 * @return
	 */
	ServerResponse findAllowance(Long appUserId);

	/**
	 * 查询我的助力红包邀请
	 * @param appUserId
	 * @return
	 */
	ServerResponse findInvitationFenSiCount(Long appUserId);


	/**
	 * 根据用户id，微信openid,淘宝id，查询APP用户列表
	 * @param appUser
	 * @return
	 */
	List<AppUser> selectAppUserListByUnionId(AppUser appUser);

	/**
	 * 修改APP用户授权首次登录
	 *
	 * @param appUser 修改APP用户授权首次登录
	 * @return 结果
	 */
	int updateAppLogin(AppUser appUser);


	/**
	 * @param userId
	 * @return
	 */
    ServerResponse invitationMakeMoney(Long userId);

	ServerResponse<JSONObject> addAlipayPhoneNumber(Long userId, String phoneNumber, String code);

	/**
	 * 更新用户可提现
	 * @param hbMoney
	 * @param userId
	 * @return
	 */
	int updateBalance(BigDecimal hbMoney, Long userId);

	/**
	 *  我的团队-->>我的下级
	 * @param userId
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
    ServerResponse<List<AppUserFansTeamVo>> findFansTeamList(Long userId, Integer pageNum, Integer pageSize);

    AppUser selectAppUserByAlipayPhoneNumber(String phoneNumber);


	/**
	 * 邀请赚钱可提现
	 * @param userId
	 * @return
	 */
	ServerResponse invitationMakeMoneyCash(Long userId);


	/**
	 * 通过用户名和支付宝账号查询用户id
	 * @param userRealName
	 * @param alipayAccount
	 * @return
	 */
    List<AppUser> selectUserByUserNameAndAlipayAccount(String userRealName, String alipayAccount);

    ServerResponse insertAlipayPhoneNumber(Long userId, String zname, String znumber, String phoneNumber);


	/**
	 * 根据公司id 批量更新用户的淘宝授权信息
	 * @param companyId
	 * @param inviteCode
	 * @param minviteCode
	 */
	int updateBatchByCompanyId(String inviteCode, String minviteCode,Integer companyId);

	/**
	 * 总邀请花费
	 * @return
	 * @param companyId
	 * @param flag
	 */
	Double totalInvitationCost(Integer companyId, Integer flag);

	/**
	 * 昨日邀请花费
	 * @return
	 */
	int invitationExpenseYesterday();

	/**
	 * 今日之前总人数（昨日总人数）
	 * @return
	 * @param flag
	 * @param companyId
	 */
	int totalNumberYesterday(Integer companyId,Integer flag);

	/**
	 * 总邀请人数
	 * @param flag
	 * @param companyId
	 * @return
	 */
	int numberOfInvitations(Integer flag, Integer companyId);

	/**
	 * 查询没有发送过指定类型的用户
	 * @param logType
	 * @return
	 */
	List<AppUser> queryAppUserSm(Integer logType);

	/**
	 * 查询用户是否复制过淘宝链接
	 * @return
	 */
	List<AppUser> sendCopyLinkMessage();

    List<AppUser> selectUserNotOrder();

	List<Long> updateUserNotOrderBlack();

	/**
	 * 查看用户一级粉丝
	 * @param userId
	 * @param currentPage
	 * @param pageSize
	 * @return
	 */
	ServerResponse<PageInfo> findUserOnesFen(Long userId, int currentPage, int pageSize);

	Long selectUserCount();

	Integer selectRegistUser(Long channelId, Integer flag);

    List<ChannelUserAffiliationVo> selectChannelUserNotAffiliation();

	int updateAppUserCompanyByUserId(Long userId, Integer companyId);

	List<AppUser> selectAppUserByTaobaoId(String taobaoUserId);

	Integer sqjdRegistNum();

	Integer sqjdAllRegistNum();

	Integer zgsAllRegistNum(Integer i);

	Integer addPayOrder(Integer type);
}
